package work.jame.blog.pojo;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Length;
import org.springframework.validation.annotation.Validated;
import work.jame.blog.framework.VerificationGroup;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 *
 * </p>
 *
 * @author Jame
 * @since 2023-05-18
 */

@TableName("comment")
public class Comment implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    @Null(message = "非法传入参数", groups = VerificationGroup.Save.class)
    private Long id;

    /**
     * 文章id
     */
    @TableField("article_id")
    @NotNull(message = "文章id不能为空",groups = VerificationGroup.Save.class)
    private Long articleId;

    /**
     * 发送用户id
     */
    @TableField("send_user_id")
    @Null(message = "非法传入参数", groups = VerificationGroup.Save.class)
    private Long sendUserId;

    /**
     * 发送的内容
     */
    @TableField("content")
    @NotNull(message = "发送的评论内容不能为空", groups = VerificationGroup.Save.class)
    @Length(min = 1, max = 1000, message = "评论长度不符合范围", groups = VerificationGroup.Save.class)
    private String content;


    /**
     * 评论类型 1根级评论 2子级评论
     */
    @TableField("comment_type")
    @Null(message = "非法传入参数", groups = VerificationGroup.Save.class)
    private Integer commentType;

    /**
     * 回复的评论id
     */
    @TableField("reply_comment_id")
    private Long replyCommentId;

    /**
     * 父级评论id
     */
    @TableField("parent_comment_id")
    private Long parentCommentId;

    @TableField("deleted")
    @TableLogic
    @Null(message = "非法传入参数", groups = {VerificationGroup.Save.class, VerificationGroup.Update.class})
    @JsonIgnore
    private Boolean deleted;

    @TableField(value = "insert_time", fill = FieldFill.INSERT)
    @ApiModelProperty(hidden = true)
    @Null(message = "非法传入参数", groups = {VerificationGroup.Save.class, VerificationGroup.Update.class})
    private LocalDateTime insertTime;

    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty(hidden = true)
    @Null(message = "非法传入参数", groups = {VerificationGroup.Save.class, VerificationGroup.Update.class})
    private LocalDateTime updateTime;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getArticleId() {
        return articleId;
    }

    public void setArticleId(Long articleId) {
        this.articleId = articleId;
    }

    public Long getSendUserId() {
        return sendUserId;
    }

    public void setSendUserId(Long sendUserId) {
        this.sendUserId = sendUserId;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Integer getCommentType() {
        return commentType;
    }

    public void setCommentType(Integer commentType) {
        this.commentType = commentType;
    }

    public Boolean getDeleted() {
        return deleted;
    }

    public void setDeleted(Boolean deleted) {
        this.deleted = deleted;
    }

    public LocalDateTime getInsertTime() {
        return insertTime;
    }

    public void setInsertTime(LocalDateTime insertTime) {
        this.insertTime = insertTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public Long getParentCommentId() {
        return parentCommentId;
    }

    public void setParentCommentId(Long parentCommentId) {
        this.parentCommentId = parentCommentId;
    }

    public Long getReplyCommentId() {
        return replyCommentId;
    }

    public void setReplyCommentId(Long replyCommentId) {
        this.replyCommentId = replyCommentId;
    }

    @Override
    public String toString() {
        return "Comment{" +
                "id=" + id +
                ", articleId=" + articleId +
                ", sendUserId=" + sendUserId +
                ", content='" + content + '\'' +
                ", commentType=" + commentType +
                ", replyCommentId=" + replyCommentId +
                ", parentCommentId=" + parentCommentId +
                ", deleted=" + deleted +
                ", insertTime=" + insertTime +
                ", updateTime=" + updateTime +
                '}';
    }
}
